package leetbook.math;

public class MissingNumber {

    public static int missingNumber(int[] nums) {
        int n = nums.length;
        int sum = (n+1)*n>>1; //0+1+...+n=(n+1)*n/2
        for (int num:nums) {
            sum -= num;
        }
        return sum;
    }
}
